<div class="crumb-wrap">
    <div class="crumb-list"><i class="icon-font"></i><a href="<?=site_url('admini')?>">首页</a>
        <span class="crumb-step">&gt;</span><a href="<?=site_url('admini/store/index')?>">商家管理</a>
        <span class="crumb-step">&gt;</span><span class="crumb-name">用户管理（<?=$store['s_name']?>）</span>
    </div>
</div>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                        <a href="<?=site_url('admini/suser/create?sid='.$store['id'])?>"><i class="icon-font"></i>新增管理帐号</a>
                    </div>
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th>用户ID</th>
                            <th>用户登录名</th>
                            <th>备注名称</th>
                            <th>权限</th>
                            <th>联系电话</th>
                            <th>最后登录时间</th>
                            <th>登录次数</th>
                            <th>操作</th>
                        </tr>
                        <?php foreach($list as $k => $v):?>
                        <tr>
                            <td><?=$v['id']?></td>
                            <td><?=$v['username']?></td>
                            <td><?=$v['name']?></td>
                            <td><?=$v['permissions'] == 1 ? '管理员' : '普通用户'?></td>
                            <td><?=$v['phone']?></td>
                            <td><?=date('Y-m-d H:i:s',$v['end_time'])?></td>
                            <td><?=$v['login_num']?></td>
                            <td>
                                <a class="link-update" href="<?=site_url('admini/suser/update?sid='.$v['id'])?>">修改</a>
                                <a class="link-update" href="javascript:set_pwd('<?=$v['id']?>')">重置密码</a>
                                <a class="link-del" href="javascript:suser_del('<?=$v['id']?>');">删除</a>
                            </td>
                        </tr>
                        <?php endforeach;?>
                    </table>
                    <div class="list-page"> <?=$page?></div>
                </div>
            </form>
        </div>
<script type="text/javascript">
layer.config({
    extend: 'extend/layer.ext.js'
});    
//prompt层
function set_pwd(sid){
    layer.prompt({
        title: '请输入密码',
        formType: 1 //prompt风格，支持0-2
    }, function(pass){
        var reg = new RegExp("^[0-9a-zA-Z_]{6,20}$");
        if(!reg.test(pass)){
            layer.alert("密码只能为字母、数字和下划线，6-20个字符",{
                icon:2,
            });
            return false;
        }
        layer.prompt({title: '请重新输入密码', formType: 1}, function(pass2){
            if(pass !== pass2){
                layer.alert("两次密码输入不一致！",{
                    icon:2,
                });
                return false;
            }

            $.post("<?=site_url('admini/suser/password')?>",{sid:sid,pass:pass},function(data){
                if(data == 1){
                    layer.alert('重置用户密码成功!',{
                        icon:1,
                    });
                }else{
                    layer.alert(data,{
                        icon:2,
                    });
                }
            });
        });
    });
}

//用户删除
    function suser_del(sid){

        $.post("<?=site_url('admini/suser/delete')?>",{sid:sid},function(res){
                if(res == 1){
                    layer.alert('删除用户成功！!',{
                        icon:1,
                    },function(){
                        location.reload(true);
                    });
                }else{
                    layer.alert(res,{
                        icon:2,
                    });
                }
        });
    }
</script>